import pytest
from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.common.by import By
import time




def LoginAndCheck(username,password):
    wd = webdriver.Edge()
    wd.implicitly_wait(10)

    wd.get('http://127.0.0.1/mgr/sign.html')

    if username is not None:
        wd.find_element(By.ID, value='username').send_keys(username)
    if password is not None:
        wd.find_element(By.ID, value='password').send_keys(password)

    wd.find_element(By.CSS_SELECTOR, value='button').click()
    time.sleep(2)


    alertText = wd.switch_to.alert.text
    print(alertText)
    return alertText



